<!--suppress ALL -->
<include file="./Template/header.html" />

<link rel="stylesheet" type="text/css" href="/Template/css/exam.css?v=3">
<script type='text/javascript' src="/Template/js/cslCamera.js"></script>
<style type="text/css">
    #btn1{
        width:200px;
        height:50px;
        background:deeppink;
        text-align:center;
        line-height:50px;
        margin:10px auto;
    }
    .album{
        width:100%;
        display:flex;
        height:auto;
        background:#999999;
        min-height:50px;
        justify-content:space-around;
        flex-wrap:wrap;
    }
    .album>div{
        width:24%;
        height:auto;
    }
    .album>div>img{
        width:100%;
    }
</style>
<script type="text/javascript" src="/Template/js/amazeui.js"></script>
<script type="text/javascript">

    $(function() {

        //初始化页面配置
        initPage("脊柱侧凸检测评估");

//        $("#pronationCheck input[type='checkbox']").click(function() {
//            lert(113);
//            if($(this).is(":checked")){
//                alert(123);
//            }
//        });
        $("textarea").keypress(function(e) {
            if (e.which == 13) {
                return false;
            }
        });

        var app = new Vue({
            el: '#container',
            data: {
            },
            methods: {
                checkRole: function(employeeRoleId, roleId) {
                    var employeeRoleArr = employeeRoleId.split(",");
                    var roleArr = roleId.split(",");

                    var result = false;
                    $.each(roleArr, function(i,val){
                        if($.inArray(val, employeeRoleArr) != -1 || $.inArray((parseInt(val)+100).toString(), employeeRoleArr) != -1){
                            result = true;
                        }
                    });
                    return result;
                },
                clearPhoto: function() {
                    photoNum = 0;
                    $("#cameraBtn").show();
                    $("#clearBtn").hide();
                    $(".photo0").attr("src", "");
                    $(".photo1").attr("src", "");
                    $(".photo2").attr("src", "");
                    $("#photo0").hide();
                    $("#photo1").hide();
                    $("#photo2").hide();
                },

                cancel: function() {
                    window.location.href = "/wechat/workorder/index/id/{$workorderId}";
                },
                save: function() {
                    var examBasicId = $("input[name=examBasicId]").val();
                    var workorderId = $("input[name=workorderId]").val();
                    var eb0 = $("input[name=eb0]").val();
                    var eb1 = $("select[name=eb1]").val();
                    var eb2 = $("input[name=eb2]").val();
                    var eb3 = $("select[name=eb3]").val();
                    var eb4 = $("input[name=eb4]").val();
                    var eb5 = $("select[name=eb5]").val();
                    var eb6 = $("select[name=eb6]").val();
                    var eb7 = $("select[name=eb7]").val();
                    var eb8 = $("input[name=eb8]").val();
                    var eb9 = $("input[name=eb9]").val();
                    var eb10 = $("select[name=eb10]").val();
                    var eb11 = $("select[name=eb11]").val();
                    var eb12 = $("select[name=eb12]").val();
                    var eb13 = $("input[name=eb13]").val();

                    if($("#photo0").is(":hidden"))
                        var photo0 = "";
                    else
                        var photo0 = $("#photo0")[0].src;
                    if($("#photo1").is(":hidden"))
                        var photo1 = "";
                    else
                        var photo1 = $("#photo1")[0].src;
                    if($("#photo2").is(":hidden"))
                        var photo2 = "";
                    else
                        var photo2 = $("#photo2")[0].src;

                    var completed = "1";
                    if(isNullOrEmpty(eb0
                            && eb1
                            && eb2
                            && eb3
                            && eb4
                            && eb5
                            && eb6
                            && eb7
                            && eb8
                            && eb9
                            && eb10
                            && eb11
                            && eb12
                            && eb13)) {
                        completed = "-1";
                    }


                    $.ajax({
                        url:"/wechat/workorder/examBasicScoPost",
                        type:"post",
                        data:{
                            examBasicId: examBasicId,
                            workorderId: workorderId,
                            eb0:eb0,
                            eb1:eb1,
                            eb2:eb2,
                            eb3:eb3,
                            eb4:eb4,
                            eb5:eb5,
                            eb6:eb6,
                            eb7:eb7,
                            eb8:eb8,
                            eb9:eb9,
                            eb10:eb10,
                            eb11:eb11,
                            eb12:eb12,
                            eb13:eb13,
                            photo0: photo0,
                            photo1: photo1,
                            photo2: photo2,

                            completed:completed,
                        },
                        dataType:"JSON",
                        beforeSend:function(){
                            $("#loadingToast").show();
                        },
                        complete:function(){
                            $('#loadingToast').hide();
                        },
                        success:function(data){
                            if(data.code == 200) {
//                                alert(data.alert);
                                alert("保存成功");
                                window.location.href = "/wechat/workorder/index/id/{$workorderId}";
                            }
                        },
                    })

                }
            }
        })
        $(".item select").change(function() {
            var value = $(this).find("option:selected").text();
            $(this).prev().val(value);
        });
    })

</script>

<div class="container" id="container">
    <div class="hint-info">
        <span class="update_time">{$formDict.update_time}：{$examBasic.update_time}</span>
        <span class="employee_name">{$formDict.update_name}：{$employeeName}</span>
    </div>
    <div class="edit-info">
        <div class="edit-content" >
            <input type="text" style="display: none;" name="workorderId" value="{$workorderId}">
            <input type="text" style="display: none;" name="examBasicId" value="{$examBasicId}">
            <div class="item"><span>柔韧度：</span><input name="eb0" type="text" value="{$examBasic.eb0}" placeholder="请输入"></div>
            <div class="item" style="border-bottom:0px">
                <span>侧凸种类：</span>
                <php>
                    $eb1Name = $formDict["scotype_".$examBasic["eb1"]];
                </php>
                <input id="eb1" type="text" value="{$eb1Name}" readonly placeholder="请选择">
                <select name="eb1">
                    <option value="{$examBasic.eb1}">请选择</option>
                    {:getFormDictSelectOptionHtml($examBasic['eb1'],'scotype','exam_basic_common',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item eb2"><span></span><input name="eb2" type="text" value="{$examBasic.eb2}" placeholder="请填写其他种类"></div>
            <div class="item">
                <span>取型方式：</span>
                <php>
                    $eb3Name = $formDict["mould_".$examBasic["eb3"]];
                </php>
                <input id="eb3" type="text" value="{$eb3Name}" readonly placeholder="请选择">
                <select name="eb3">
                    <option value="{$examBasic.eb3}">请选择</option>
                    {:getFormDictSelectOptionHtml($examBasic['eb3'],'mould','exam_basic_common',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <!--<div class="item"><span>Rigo色努分型：</span><input name="eb4" type="text" value="{$examBasic.eb4}" placeholder="请输入"></div>-->

            <div class="item" style="border-bottom:0px">
                <span class="itemTitle" style="margin-left: 30%">—— 临床评估 ——</span><br/>
            </div>
            <div class="item" style="border-bottom:0px">
                <span>躯干代偿偏向：</span>
                <php>
                    $eb5Name = $formDict["trunk_".$examBasic["eb5"]];
                </php>
                <input id="eb5" type="text" value="{$eb5Name}" readonly placeholder="请选择">
                <select name="eb5">
                    <option value="{$examBasic.eb5}">请选择</option>
                    {:getFormDictSelectOptionHtml($examBasic['eb5'],'trunk','exam_basic_common',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item" style="border-bottom:0px">
                <span>病人站立-骨盆转向：</span>
                <php>
                    $eb6Name = $formDict["pelvis_".$examBasic["eb6"]];
                </php>
                <input id="eb6" type="text" value="{$eb6Name}" readonly placeholder="请选择">
                <select name="eb6">
                    <option value="{$examBasic.eb6}">请选择</option>
                    {:getFormDictSelectOptionHtml($examBasic['eb6'],'pelvis','exam_basic_common',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item" style="border-bottom:0px">
                <span>病人前屈-骨盆转向：</span>
                <php>
                    $eb7Name = $formDict["pelvis_".$examBasic["eb7"]];
                </php>
                <input id="eb7" type="text" value="{$eb7Name}" readonly placeholder="请选择">
                <select name="eb7">
                    <option value="{$examBasic.eb7}">请选择</option>
                    {:getFormDictSelectOptionHtml($examBasic['eb7'],'pelvis','exam_basic_common',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>

            <div class="item eb8" style="border-bottom:0px;"><span>顶椎（胸）：</span><input name="eb8" type="text" value="{$examBasic.eb8}" placeholder="请填写"></div>
            <div class="item eb9" style=""><span>顶椎（腰）：</span><input name="eb9" type="text" value="{$examBasic.eb9}" placeholder="请填写"></div>

            <div class="item">
                <span class="itemTitle" style="margin-left: 30%">—— 相关资料 ——</span>
                <br/>
                <div class="item" style="border-bottom:0px">
                    <span>X光片：</span>
                    <php>
                        $eb10Name = $formDict["yesorno_".$examBasic["eb10"]];
                    </php>
                    <input id="eb10" type="text" value="{$eb10Name}" readonly placeholder="请选择">
                    <select name="eb10">
                        <option value="{$examBasic.eb10}">请选择</option>
                        {:getFormDictSelectOptionHtml($examBasic['eb10'],'yesorno','exam_basic_common',0)}
                    </select>
                    <img class="icon-right" src="/Template/images/icon-right.png" alt="">
                </div>
                <div class="item" style="border-bottom:0px">
                    <span>检查照片：</span>
                    <php>
                        $eb11Name = $formDict["yesorno_".$examBasic["eb11"]];
                    </php>
                    <input id="eb11" type="text" value="{$eb11Name}" readonly placeholder="请选择">
                    <select name="eb11">
                        <option value="{$examBasic.eb11}">请选择</option>
                        {:getFormDictSelectOptionHtml($examBasic['eb11'],'yesorno','exam_basic_common',0)}
                    </select>
                    <img class="icon-right" src="/Template/images/icon-right.png" alt="">
                </div>
                <div class="item" style="border-bottom:0px">
                    <span>其他资料：</span>
                    <php>
                        $eb12Name = $formDict["yesorno_".$examBasic["eb12"]];
                    </php>
                    <input id="eb12" type="text" value="{$eb12Name}" readonly placeholder="请选择">
                    <select name="eb12">
                        <option value="{$examBasic.eb12}">请选择</option>
                        {:getFormDictSelectOptionHtml($examBasic['eb12'],'yesorno','exam_basic_common',0)}
                    </select>
                    <img class="icon-right" src="/Template/images/icon-right.png" alt="">
                </div>
                <div class="item" style="border-bottom:0px"><span>描述：</span><input name="eb13" type="text" value="{$examBasic.eb13}" placeholder="请填写描述"></div>

                <div class="camera-btn" id="cameraBtn">上传照片</div>
                <div class="clear-btn" id="clearBtn" v-on:click="clearPhoto">清空照片</div>
                <div style="margin-top:2rem;height: 10rem;">
                    <img class="photoAlbum" id="photo0" src="{$workorder.photo0}"/>
                    <img class="photoAlbum" id="photo1" src="{$workorder.photo1}"/>
                    <img class="photoAlbum" id="photo2" src="{$workorder.photo2}"/>
                </div>
            </div>



        </div>

    </div>
    <div class="operation-btn">
        <div class="cancle-btn" v-on:click="cancel">取消</div>
        <if condition="$workorder['status'] eq '-1' && $workorder['creator_id'] eq $customerId">
           <div class="save-btn" v-on:click="save">保存</div>
        </if>
        <if condition="$workorder['status'] eq '2' && $workorder['examinator_id'] eq $customerId">
            <div class="save-btn" v-on:click="save">保存</div>
        </if>
        <div v-if="{$workorder.status} >= 1 && checkRole('{$role}', '1')">
            <div class="save-btn" v-on:click="save">保存</div>
        </div>
    </div>

</div>
<script type="text/javascript">
    var img=$(".img");
    var photoNum = 0;
//    var divTar = $("#cameraBtn");
        var callBack=function(album){

            album.forEach(function(val,idx){
//            var div=$("<div></div>");
//            var img=$("<img/>");
//            img.attr("src",val.data);
//            div.append(img);
                $("#cameraBtn").hide();
                $("#clearBtn").hide();
                $(".save-btn").hide();
                $.ajax({
                    url:"/wechat/workorder/getImageUrl",
                    type:"post",
                    data:{
                        imgData: val.data,
                    },
                    dataType : 'json',
                    success : function (data, status){
                        switch(photoNum){
                            case 0:
//                                $("#cameraBtn").html("侧位照片");
                                $("#photo0").attr("src", data);
                                $("#photo0").show();
                                $("#cameraBtn").show();
                                break;
                            case 1:
//                                $("#cameraBtn").html("其他照片");
                                $("#photo1").attr("src", data);
                                $("#photo1").show();
                                $("#cameraBtn").show();
                                break;
                            case 2:
                                $("#photo2").attr("src", data);
                                $("#photo2").show();
                                break;
                        }
                        $("#clearBtn").show();
                        $(".save-btn").show();
                        photoNum++;
                    },
                    error: function(data, status, e){
                        alert(e);
                    }
                })
//            $(".album").append(div);

            });

    }
    var carera=new $.Pgater($("#cameraBtn"),callBack);
</script>
<include file="./Template/footer.html" />